package antrace;

import processing.core.PFont;
import processing.core.PImage;

public class Overlay implements InterfaceView{

	protected PImage[] images;
	protected OverlayText[] texts;
	protected PFont font;
	
	protected byte selectedIndex = 0;
	
	protected boolean showOverlay = false;

	public Overlay(PImage overlayBackground) {
		images = new PImage[2];
		texts = new OverlayText[2];
		images[0] = new PImage(240,320);
		images[1] = overlayBackground;
		
	}
	
	public Overlay(PImage overlayBackground, OverlayText[] messages) {
		images = new PImage[2];
		images[0] = new PImage(240,320);
		images[1] = overlayBackground;
		texts = messages;
	}
	
	public void setLastFrame(PImage lastFrame){
		images[0] = lastFrame;
	}

	public void toggleVisible() {
		showOverlay = !showOverlay;
	}
	
	public boolean isVisible(){
		return showOverlay;
	}
	
	protected void updateSelects(){
		for(int i=0; i < texts.length; i++){
			if(i == selectedIndex)
				texts[i].select();
			else
				texts[i].deselect();
		}
	}
	
	public void draw() {
		for (int i = 0; i < images.length; i++) {
			AntRace.midlet.image(images[i], 0, 0);
		}
		for (int i = 0 ;i < texts.length; i++) {
			texts[i].draw();
		}
	}

	public void keyPressed(int keyCode){
		
	}

	public void keyReleased(int keyCode) {
		
	}

}
